// pages/propertyNews.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pages: 1,
    phoneList: []
  },
  callPhone: function (e) {
    console.log(e.currentTarget.dataset.phone)
    //拨打电话
    var that = this
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.phone,
      success: function () {
        console.log("成功拨打电话")
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let _this = this;
    wx.request({
      url: getApp().data.servsers + '/phone/list',
      header: {
        'content-type': 'application/json'
      },
      data: {
        startPage: _this.data.pages,
        PageSize: 10
      },
      success(res) {
        if (res.data.status == 'success') {
          _this.setData({
            pages: _this.data.pages += 1
          })
          _this.setData({
            phoneList: res.data.data.list
          })
        }
      }
    })
  },
  onReachBottom: function () {
    let _this = this;
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: getApp().data.servsers + '/phone/list',
      header: {
        'content-type': 'application/json'
      },
      data: {
        startPage: _this.data.pages,
        PageSize: 10
      },
      success(res) {
        console.log(res)
        if (res.data.status == 'success') {
          wx.hideLoading()
          _this.setData({
            pages: _this.data.pages += 1
          })
          if (_this.data.phoneList.length < res.data.data.total) {
            _this.setData({
              phoneList: _this.data.phoneList.concat(res.data.data.list)
            })
          }
        }
      }
    })
  }
})